<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('师傅申请配件列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>工单号：</label>
                                <input type="text" name="orderId"/>
                            </li>
                            <li>
                                <label>配件单号：</label>
                                <input type="text" name="id"/>
                            </li>
                            <li>
                                <label>申请状态：</label>
                                <select name="partsState" th:with="type=${@dict.getType('parts_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">是否需要返件：</label>
                                <select name="isReturn" th:with="type=${@dict.getType('zsyh_yesno')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>申请时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zsyh:serviceOrderParts:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:serviceOrderParts:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:serviceOrderParts:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:serviceOrderParts:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:serviceOrderParts:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:serviceOrderParts:remove')}]];
        var partsStateDatas = [[${@dict.getType('parts_state')}]];
        var isReturnDatas = [[${@dict.getType('zsyh_yesno')}]];
        var prefix = ctx + "zsyh/serviceOrderParts";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "师傅申请配件",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    align: 'center',
                    title: '配件单号',
                },
                {
                    field: 'orderId',
                    align: 'center',
                    title: '工单号',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs " href="javascript:void(0)" onclick="viewOrderDetail(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>'+row.orderId+'</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'repairStorePerson',
                    align: 'center',
                    title: '申请师傅名称'
                },
                    {
                        field: 'repairStorePhone',
                        align: 'center',
                        title: '申请师傅电话'
                    },
                {
                    field: 'partsState',
                    align: 'center',
                    title: '申请状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(partsStateDatas, value);
                    }
                },
                /*{
                    field: 'partsContent',
                    title: '拒绝原因'
                },*/
                {
                    field: 'imagesMachine',
                    align: 'center',
                    title: '整机外形图片',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a  href="javascript:void(0)" onclick="openAttributeImage(\'' + row.imagesMachine + '\')">查看</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'imagesCode',
                    align: 'center',
                    title: '整机条码或铭牌图片',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a  href="javascript:void(0)" onclick="openAttributeImage(\'' + row.imagesCode + '\')">查看</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'imagesFault',
                    align: 'center',
                    title: '故障配件图片',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a  href="javascript:void(0)" onclick="viewImage(\'' + row.id + '\')">查看</a> ');
                        return actions.join('');
                    }
                },
               /* {
                    field: 'userName',
                    title: '收件人'
                },
                {
                    field: 'userPhone',
                    title: '收件手机号'
                },
                {
                    field: 'userAddress',
                    title: '收件地址'
                },
                {
                    field: 'logisticsId',
                    title: '快递公司id'
                },
                {
                    field: 'logisticsName',
                    title: '快递公司名称'
                },
                {
                    field: 'logisticsNumber',
                    title: '快递单号'
                },
                {
                    field: 'logisticsProof',
                    title: '物流凭证'
                },
                {
                    field: 'logisticsRemarks',
                    title: '备注'
                },*/
                {
                    field: 'isReturn',
                    align: 'center',
                    title: '是否需要返件',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(isReturnDatas, value);
                    }
                },
                /*{
                    field: 'factoryName',
                    title: '厂家收件人'
                },
                {
                    field: 'factoryPhone',
                    title: '厂家收件手机号'
                },
                {
                    field: 'factoryAddress',
                    title: '厂家收件地址 '
                },
                {
                    field: 'returnLogisticsId',
                    title: '退回旧配件 快递公司id'
                },
                {
                    field: 'returnLogisticsName',
                    title: '退回旧配件 快递公司名称'
                },
                {
                    field: 'returnLogisticsNumber',
                    title: '退回旧配件 快递单号'
                },
                {
                    field: 'returnLogisticsProof',
                    title: '物流凭证'
                },
                {
                    field: 'returnLogisticsRemarks',
                    title: '备注'
                },*/
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="virePartsDetail(\'' + row.id + '\')"><i class="fa fa-search"></i>查看详情</a> ');
                        /*actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function openAttributeImage(attributeImage) {
            $.modal.open("查看图片", attributeImage.split("|"));
        }

        function viewImage(id) {
            var url = prefix + "/viewImage/"+id;
            layer.open({
                type: 2,
                area: [$(window).width()/1.5 + 'px', ($(window).height() - 50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看图片",
                content: url,
                btnClose: 1,
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    debugger;
                    var iframeWin = layero.find('iframe')[0];
                    /*var imageUrl = layero.find('iframe')[0].contentWindow.$("#imageUrl").val();*/
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

        function viewOrderDetail(orderId) {
            $.modal.openTab("查看工单详情",ctx + "zsyh/serviceOrder/edit/"+orderId+"/2");
        }

        function virePartsDetail(id) {
            $.modal.openTab("查看配件单详情",prefix + "/edit/"+id);
        }

    </script>
</body>
</html>